package com.blockmeta.bbs.minemodule.activity;

import android.view.View;

import com.blockmeta.bbs.baselibrary.utils.gson.GsonUtil;
import com.blockmeta.bbs.businesslibrary.activity.BaseListActivity;
import com.blockmeta.bbs.businesslibrary.constant.NetConstant;
import com.blockmeta.bbs.minemodule.R;
import com.blockmeta.bbs.minemodule.adapter.AirDropListAdapter;
import com.blockmeta.bbs.minemodule.pojo.AirDropPOJO;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.google.gson.reflect.TypeToken;
import com.scwang.smartrefresh.layout.api.RefreshLayout;

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.List;

/**
 * Created by author on 2018/7/11.
 */

public class AirDropListActivity extends BaseListActivity<List<AirDropPOJO>> {

    @Override
    public boolean showTitleBar() {
        return true;
    }

    @Override
    protected View addCHooseHeaderView() {
        return null;
    }

    @Override
    protected void initBundle() {
        setTitleText("空投活动");
    }

    @Override
    public BaseQuickAdapter initAdapter() {
        return new AirDropListAdapter(R.layout.activity_list_airdrop, null, mContext);
    }

    @Override
    public String getUrl() {
        return NetConstant.AIRDROP_ACTIVITY;
    }

    @Override
    public HashMap<String, String> initHashMap() {
        return null;
    }

    @Override
    public List<AirDropPOJO> parseData(String resp) {
        Type type = new TypeToken<List<AirDropPOJO>>() {
        }.getType();
        return GsonUtil.buildGson().fromJson(resp, type);
    }

    @Override
    protected void adapterSetData() {
        mAdapter.setNewData(mPOJO);
    }

    @Override
    protected void adapterAddData() {
        list_swipe.finishLoadmore();
    }

    @Override
    public void onLoadmore(RefreshLayout refreshlayout) {
        list_swipe.finishLoadmore();
        list_swipe.setEnableLoadmore(false);
    }

    @Override
    public void onRefresh(RefreshLayout refreshlayout) {
        initNet(false);
    }
}
